package com.example.newsSys.exceptionHandler;

import com.example.newsSys.vo.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

// 全局异常处理
@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(RuntimeException.class)
    @ResponseBody
    public Result handleRuntimeException(RuntimeException ex) {
        log.info(ex.getMessage() + "非法访问，将为您重定向");
        return Result.ERROR(302,"用户未登录");
    }
}
